package com.woniuxy.service.serviceImpl;

import com.woniuxy.dao.UserDao1;
import com.woniuxy.entity.User;
import com.woniuxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author: ideaAdmin
 * Date: 2022/1/19:15:35
 * Description:
 */
@Service("userService") //设置当前类是service 设置bean名字为userService
public class UserServiceImpl implements UserService {
    @Autowired //通过注解来自动装配 默认属于byType
    UserDao1 userDao;


    @Override
    public List<User> findAll(Integer id) {
        return userDao.findAll(id);
    }


    @Override
    public User insertUser(User user) {
        userDao.insertUser(user);
        user.setStatus("1");
        user.setId(13);
        updateUser(user);//调用updateUser的方法
        int i = 1 / 0;
        return user;

    }

    //根据id更改用户状态
    @Override
    public boolean updateUser(User user) {
        userDao.updateUser(user);
        return  false;
    }

    //根据id删除id
    @Transactional
    @Override
    public boolean delById(User user) {
        return userDao.delById(user) > 0;
    }


}
